package com.jinzhu.common.exception;

import lombok.Getter;

/**
 * @Author: jz
 * @Date: 2021/12/7 18:29
 * @Description 数据校验异常
 */
@Getter
public class DataValidateException extends Exception {
    
    private static final long serialVersionUID = 1741078348564045051L;
    
   
    private Integer errorCode;
    private String desc;
    
    public DataValidateException() {
        this.desc = "";
    }
    
    public DataValidateException(String desc) {
        this.errorCode = CommonEnum.INTERNAL_SERVER_ERROR.getResultCode();
        this.desc = desc;
    }
    
    
    public DataValidateException(String desc, Integer errorCode) {
        this.desc = desc;
        this.errorCode = errorCode;
    }
    
    public DataValidateException(CommonEnum errorMessageEnum) {
        this.errorCode = errorMessageEnum.getResultCode();
        this.desc = errorMessageEnum.getResultMsg();
    }
    
    
    public DataValidateException(CommonEnum errorMessageEnum, String appendMessage) {
        this.desc = appendMessage + errorMessageEnum.getResultMsg();
        this.errorCode = errorMessageEnum.getResultCode();
    }
    
    public DataValidateException(CommonEnum errorMessageEnum, String... messageParam) {
        this.desc = String.format(errorMessageEnum.getResultMsg(), messageParam);
        this.errorCode = errorMessageEnum.getResultCode();
    }
    
    
    public DataValidateException(String desc, Throwable t) {
        super(desc, t);
        this.desc = desc;
    }
    
}
